<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<link href="/static/css/default.css" rel="stylesheet" type="text/css">
<link href="/static/css/style/green.css" rel="stylesheet" type="text/css" id = 'link'>
<link rel="stylesheet" href="/static/kindeditor/themes/default/default.css" />
<script charset="utf-8" src="/static/kindeditor/kindeditor-min.js"></script>
<script charset="utf-8" src="/static/kindeditor/lang/zh-CN.js"></script>
<link rel="stylesheet" href="/static/FileUpload/css/jquery.fileupload.css" />
</head>

<body style="overflow:hidden; padding:10px;">
	<form>
    <table class="formtable" style="width:580px;" id="app" >
    
    <tbody>
    
    	<tr>
        <td class="tlabel">标题</td>
        <td>
		<input type="text" class="forminput inputstyle1" id="title" value="">
		</td>
        </tr>
        <tr>
        <td class="tlabel">内容</td>
        <td>
        <textarea  id="desc"  class="formarea"></textarea>
        
		</td>
        </tr>
        <tr>
            <td class="tlabel">接收人</td>
            <td>
                <div>
                        <li  style="width:80px;float:left;">

                                <input type="checkbox"  id="allchoose"   /> 全选
                           
                    </li>
                        <li  v-for="uitem in list" style="width:80px;float:left;">

                                        <input type="checkbox" :value="uitem.id" v-model="check" name="user" v-bind:truename="uitem.truename"  />
                                    {{uitem.truename}}
                            </li>
                </div>
               
            </td>
            </tr>
        <tr>
                <td class="tlabel">发送人</td>
                <td>
                <input type="text" class="forminput inputstyle1" id="sendusername" value="">
                </td>
                </tr>
              

        
        
    </tbody>
    
    </table>
    
    <div class="formbtn">
    <input type="button" value="提交"  class="btnsave">
    <input type="button" value="取消"  class="btncancel">
    </div>
    <input type="hidden" id="id" value="{$info.id}" />
    <input type="hidden" id="imgurl" value="{$info.imgurl}" />
</form>


</body>
	<script type="text/javascript" src="/static/js/jquery.js"></script>
    <script type="text/javascript" src="/static/js/common.js"></script>
	<script type="text/javascript" src="/static/js/vue2.js"></script>
    <script src="/static/js/layer/layer.js"></script>
    <script src="/static/My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript" src="/static/js/vue2.js"></script>
<script>
 var vue = new Vue({
        el: '#app',
        data: {
            list: [],
            check:[]
        },
        methods: {
            getdata: function () {
                var _self = this;//保存this的指向
                $.post('/index/student/GetStudentList',{}, function (data) {
				console.log(data);
                    _self.list = data;
                });
            }

        },
        created: function () {  //初始化事件里边去调用查询方法
            this.getdata();
        }
    });
  
	$(function(){
        $("#allchoose").change(function() { 
            if($(this).is(':checked')){
                vue.$data.check=true;
            }else{
                vue.$data.check=false;
            }
        });
     
			
    });

    
    
  
		$(".btnsave").click(function(){
            
           
			 var id = $("#id").val();
            var title = $("#title").val();
            var desc = $("#desc").val();
			var sendusername = $("#sendusername").val();
            var users = [];
                $("[name=user]:checked").each(function () {
                    var obj = {};
                    obj["id"]=$(this).val();
                    obj["truename"]=$(this).attr("truename");
                    users.push(obj);
                });
            if(title==""){
                layer.msg("请输入标题");
            }else if(title.length>150){
                layer.msg("内容过长");
            }else if(users.length==0){
                layer.msg("请选择接收人");
            }else if(sendusername==""){
                layer.msg("请输入发送人");
            }else{
            
                users = JSON.stringify(users); 
        
                $.post("/Index/daily/messageadd", { "id": id, "title":title, "desc": desc,"users":users,"sendusername":sendusername}, function (data) {
                    if (data.status == 200) {
                        var index = parent.layer.getFrameIndex(window.name);
                        window.parent.iframe.contentWindow.location.reload(true);
                        console.log(window.parent.iframe);
                        parent.layer.close(index);
                    }else{
                        layer.msg(data.message);
                    }
                });

            }
         
           
		});
		$(".btncancel").click(function(){
			var index = parent.layer.getFrameIndex(window.name);
			parent.layer.close(index);
		});

   

</script>
</html>
